<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:76:"E:\workplace\project\Sunwm\web/../application/admin\view\redpacket\edit.html";i:1512633498;s:75:"E:\workplace\project\Sunwm\web/../application/admin\view\public\header.html";i:1503189484;s:73:"E:\workplace\project\Sunwm\web/../application/admin\view\public\city.html";i:1510310973;s:75:"E:\workplace\project\Sunwm\web/../application/admin\view\public\footer.html";i:1512624954;}*/ ?>
﻿<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title><?php echo config('sitename'); ?>-<?php echo lang('label')['Login_title']; ?></title>
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/public/css/pintuer.css" />
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/admin/css/admin.css" />
		<script type="text/javascript" src="__ROOT__/static/public/js/jquery.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/js/pintuer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/admin/js/admin.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/layer/layer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laydate/laydate.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laytpl/laytpl.js"></script>
	</head>

	<body>
	<style>
		html { overflow-x:hidden; }
	</style>
	<form method="post" class="form-x" action="<?php if($data['id']): ?>?id=<?php echo $data['id']; endif; ?>">
	<div class="panel admin-panel">
		<div class="panel-head"><strong><?php echo lang('currency')['edit']; ?></strong></div>
            <br/>
            <script>
                //city canshu
                var pid='<?php echo input("get.pid"); ?>';
                var cid='<?php echo input("get.cid"); ?>';
                var aid='<?php echo input("get.aid"); ?>';
                if(!aid){
                    var pid='<?php echo $data['pid']; ?>';
                    var cid='<?php echo $data['cid']; ?>';
                    var aid='<?php echo $data['aid']; ?>';
                }
                var selectc=true;
                var selecta=true;
                function select_p() {
                }
                function select_c() {
                }
                function select_a() {
                    location.href = '?pid='+pid+'&cid='+cid+'&aid='+aid;
                }
            </script>

            <div class="form-group">
                <div class="label">
                    <label><?php echo lang('currency')['city']; ?></label>
                </div>
                <div class="field">
                    <?php if(input('session.type') == 'province' || input('session.type') == 'all'): ?>
<select id="province" onchange="pchange(this.value)" name="pid" class="input input-auto" >
	<option value="">请选择</option>
</select>
<?php endif; if(input('session.type') == 'province' ||  input('session.type') == 'city' || input('session.type') == 'all'): ?>
<select id="city" onchange="cchange(this.value)" name="cid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<?php endif; ?>
<select id="area" onchange="achange(this.value)" name="aid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<script id="province_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==pid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="city_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==cid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="area_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==aid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
    var func = false;
    $('select').click(function(){
        func = true;
    });
    if(selectc) {
        $('[name=cid]').removeClass('hidden');
    }
    if(selecta){
        $('[name=aid]').removeClass('hidden');
    }
    if('<?php echo input("session.type"); ?>' == 'province' || '<?php echo input("session.type"); ?>' == 'all') {
        $.getJSON('__ROOT__/admin/city/ajax_get?type=province', {}, function (res) {
            var tpl = $("#province_list_tpl").html();
            laytpl(tpl).render(res, function (render) {
                $("#province").html('<option value="">请选择</option>' + render);
            });
            if (pid != '' && pid != 0) {
                $('[name=pid]').change();
            }
        });
    }else if('<?php echo input("session.type"); ?>' == 'city'){
        val = '<?php echo input("session.aid"); ?>';
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+val, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>' + render);
                    $("#city").val(cid);
                    $("#city").change();
                });
            });
        }
    }else if('<?php echo input("session.type"); ?>' == 'area'){
        val = '<?php echo input("session.aid"); ?>';
        //if(selecta && aid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&nofather=ok&id='+val, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
       // }
    }
    function pchange(val) {
        pid = val;
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+pid, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>'+render);
                });
                if(selectc == true){
                    if(cid != '' && cid != 0){
                        $('[name=cid]').change();
                    }
                }
            });
        }
        if(func){
            select_p();
        }
    }
    function cchange(val) {
        cid = val;
        if(selecta && cid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&id='+cid, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
        }
        if(func){
            select_c();
        }
    }
    function achange(val) {
        aid = val;
        $('[name=aid]').removeClass('hidden');
        if(func){
            select_a();
        }
    }
</script>
                </div>
            </div>
            <?php if(input('get.aid') || $data['aid']): ?>
                <div class="form-group">
                    <div class="label">
                        <label>关联商家</label>
                    </div>
                    <div class="field">
                        <ul class="list-inline" style="padding: 0;margin-top: 8px">
                            <li>
                                <label>
                                    <input type="checkbox" id="_box" name="seller_id[]" value="" onclick="$('.box').removeAttr('checked');" <?php if(!$data['seller_id']): ?>checked="checked"<?php endif; ?> /> 全部
                                </label>
                            </li>
                            <br>
                            <?php foreach($seller as $k => $v): ?>
                                <li>
                                    <label>
                                        <input type="checkbox" class="box" name="seller_id[]" onclick="$('#_box').removeAttr('checked');" id="<?php echo $v['id']; ?>_box" value="<?php echo $v['id']; ?>" /> <?php echo $v['name']; ?>
                                    </label>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>红包标题</label>
                    </div>
                    <div class="field">
                        <input type="text" class="input input-auto" id="title" name="title" value="<?php echo $data['title']; ?>" size="20" placeholder="请输入红包标题" data-validate="required:<?php echo lang('currency')['required']; ?>" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>数量</label>
                    </div>
                    <div class="field">
                        <input type="number" class="input input-auto" id="number" name="number" value="<?php echo $data['number']; ?>" size="20" placeholder="请输入发放数量" data-validate="required:<?php echo lang('currency')['required']; ?>" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>满足条件</label>
                    </div>
                    <div class="field">
                        <input type="text" class="input input-auto" id="full" name="full" value="<?php echo $data['full']; ?>" size="30" placeholder="请输入满足条件，否则无门槛" data-validate="required:<?php echo lang('currency')['required']; ?>" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>红包金额</label>
                    </div>
                    <div class="field">
                        <input type="text" class="input input-auto" id="minus" name="minus" value="<?php echo $data['minus']; ?>" size="30" placeholder="请输入减免金额" data-validate="required:<?php echo lang('currency')['required']; ?>" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>有效时间</label>
                    </div>
                    <div class="field">
                        <input type="number" class="input input-auto" id="indate" name="indate" value="<?php echo $data['indate']; ?>" size="30" placeholder="请输入有效时间" data-validate="required:<?php echo lang('currency')['required']; ?>" /> 天
                    </div>
                </div>
                <div class="form-group">
                    <div class="label">
                        <label>使用时间</label>
                    </div>
                    <div class="field">
                        <input type="text" class="input input-auto" id="intime" name="intime" value="<?php echo $data['intime']; ?>" size="30" placeholder="请输入使用时间" /> 如：10-12限制10点至12点使用，不填则不限制
                    </div>
                </div>
                <div class="form-button">
                    <button class="button bg-main" type="submit"><?php echo lang('form')['submit']; ?></button>
                </div>
                <br>
            <?php else: ?>
                <div class="form-group" style="margin-bottom: 10px">
                    <div class="label">
                        <label></label>
                    </div>
                    <div class="field">
                        请选择城市后设置
                    </div>
                </div>
            <?php endif; ?>
		</div>
	</form>
<?php if(input('get.aid') || $data['aid']): ?>
<script>
    var seller = '<?php echo $data['seller_id']; ?>';
    var seller_array = seller.split(',');
    for(var i in seller_array){
        if(seller_array[i])
            document.getElementById(seller_array[i]+'_box').checked = 'checked';
    }
</script>
<?php endif; ?>
<p class="text-center text-gray" style="margin-top:10px;"><a class="text-gray" target="_blank" href="http://www.wm0530.com">完美外卖系统 Power by 网络工厂</a></p>
</body>
<script>
$('.upload').on('click',function (){
		var id = $(this).attr('data-id');
		 upload(id);
	}
);
function upload(id){
	layer.open({
		type:2,
		title:false,
		area: ['70%', '90%'],
		offset: '5%',
		content: "<?php echo url('/admin/material'); ?>?id="+id
	});
}
</script>
</html>